/*
	Copyright (C) 2009 jungil Han <jungil.Han@gmail.com>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __MKMAINDIALOG_H__
#define __MKMAINDIALOG_H__

#include "../Base/Dialog/mkDialog.h"
#include "../Base/Button/mkButton.h"
#include "../Button/mkHotkeyButton.h"
#include "mkAboutDialog.h"
#include "mkKeyboardDialog.h"
#include "mkURLDialog.h"

#include <QSystemTrayIcon>

class QWidget;
class QButtonGroup;
class QMenu;

enum eSLINDING_DIRECTION {
	eSlidingLeft = 0,
	eSlidingRight,
};

class mkMainDialog : public mkDialog {
	Q_OBJECT

public:
    mkMainDialog( IN QWidget *a_pParent = 0, IN Qt::WindowFlags eWindowFlags = 0 );
	~mkMainDialog();

	bool IsEnableHotkey();
	void UpdateTrayIconToolTip();
	
	QString ShowURLDialog( IN const QString &a_refCurrentUrl );

	void Execute( IN QString &a_refFileName );

public slots:
	void SlotKeyboardShow( int a_nHotkeyButtonID);
	void SlotHotkeyInfoUpdated( QString a_strSystemKey, QString a_strNonSystemKey );
	void SlotQuit();

protected:
	virtual void OnInitDialog();

	void LoadHotkeyInfo();
	void AddHotkeyButton();
	void RemoveEmptyButton();

	virtual void hideEvent( QHideEvent *a_pEvent );
	virtual void wheelEvent( QWheelEvent *a_pEvent );
	virtual void closeEvent( QCloseEvent *a_pEvent );
	virtual void keyPressEvent( QKeyEvent *a_pEvent );
	virtual bool winEvent( MSG *a_pMessage, long *a_pResult );

protected slots:
	void SlotLeftClicked();
	void SlotRightClicked();
	void SlotAlignClicked();
	void SlotAddClicked();

	void SlotShowAbout();
	void SlotEnableAutoRun();
	void SlotDisableAutoRun();
	void SlotEnableHotkey();
	void SlotDisableHotkey();
	void SlotSlidingEffect();

	void SlotTrayIconActivated( QSystemTrayIcon::ActivationReason a_eReason );

private:
	QWidget *m_pTransparentWindow;
	mkAboutDialog *m_pAboutDialog;
	mkKeyboardDialog *m_pKeyboardDialog;
	mkURLDialog *m_pURLDialog;

	QButtonGroup *m_pHotkeyButtonGroup;
	mkButton *m_pLeftButton;
	mkButton *m_pLeftExtButton;
	mkButton *m_pRightButton;
	mkButton *m_pRightExtButton;

	QSystemTrayIcon *m_pTrayIcon;
	QMenu *m_pTrayIconMenu;
	QAction *m_pAboutAction;
	QAction *m_pEnableAutoRunAction;
	QAction *m_pDisableAutoRunAction;
	QAction *m_pEnableAction;
	QAction *m_pDisableAction;
	QAction *m_pQuitAction;

	int m_nClickedButtonID;

	int m_nSlidingCount;
	int m_nSlidingDirection;
	QTimer *m_pSlidingTimer;

	bool m_bIsSliding;
	bool m_bIsHotkeyAdd;
	bool m_bIsAligned;
	bool m_bIsEnableHotkey;

	int m_nPosX, m_nPosY;
};

#endif // EZMAINDIALOG_H
